//# sourceURL=http://uMapApp/UI/Panel/PanelBlock/PanelBlock
define([
    "mhjs/mhjs",
    "./BlockTitle",
    "./BlockWrap"
], function (
    mhjs,
    BlockTitle,
    BlockWrap
) {

    function PanelBlock(option) {

        var _this = this;
        _this.isOpened = false;

        _this.ui = _this.ui || {};
        _this.ui.title = new BlockTitle();
        _this.ui.buttons = new mhjs.Div({"class": "buttons"});
        _this.ui.wrap = new BlockWrap();


        mhjs.Div.call(_this, option);
        _this.addClass("block");

        _this
            .append(_this.ui.title)
            .append(_this.ui.wrap)
            .append(_this.ui.buttons)
        ;

    }

    var _class = PanelBlock;
    mhjs.Inherit(_class, mhjs.Div);


    Object.defineProperties(_class.prototype, {
        "title"    : {
            set: function (title) {
                var _this = this;
                _this._title = title;
                _this.ui.title.title = title;
            },
            get: function () {
                return this._title;
            }
        },
        "content"  : {
            set: function (content) {
                var _this = this;
                _this.clear();
                _this._content = content;
                _this.ui.wrap.append(content);
            },
            get: function () {
                return this._content;
            }
        },
        "clear"    : {
            value: function () {
                var _this = this;
                _this.ui.wrap.empty();
                _this._content = undefined;
            }
        },
        "open"     : {
            value: function () {
                var _this = this;
                _this.isOpened = true;
                _this.addClass("open");
            }
        },
        "close"    : {
            value: function () {
                var _this = this;
                _this.isOpened = false;
                _this.removeClass("open");
            }
        },
        "toggle"   : {
            value: function () {
                var _this = this;
                if (_this.isOpened) {
                    _this.close();
                } else {
                    _this.open();
                }
            }
        },
        "addButton": {
            value: function (button) {
                var _this = this;
                _this.ui.buttons.append(button);
                return button;
            }
        }
    });

    return _class;

});